import { Global, Module } from '@nestjs/common';
import { NacosService } from './nacos.service';
import { NacosConfigClient, NacosNamingClient } from 'nacos';
import { NacosController } from './nacos.controller';

@Global()
@Module({
  providers: [
    NacosService,
    {
      provide: 'NACOS_CLIENT',
      async useFactory() {
        const client = new NacosNamingClient({
          serverList: ['127.0.0.1:8848'],
          namespace: 'public',
          logger: console
        })
        await client.ready()
        return client
      }
    },
  ],
  exports: [NacosService],
  controllers: [NacosController]
})
export class NacosModule {

}
